﻿@model MvcCmsOptIn.Models.OptInModel                  
@section HtmlHead{
    <link href="@Url.Content("/areas/mvccmsoptin/content/demo_page.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("/areas/mvccmsoptin/content/demo_table.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("/areas/mvccmsoptin/content/demo_table_jui.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("/areas/mvccmsoptin/content/start/jquery-ui-1.8.11.custom.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("/RazorThemes/" + Model._Portal.SkinName + "/css/optin.css")" rel="stylesheet" type="text/css" />
}
<div class="contentpage-outerdiv">
    <div id="container">
        <div class="breadcrumb">
            <span><a href="/optin-manager">Main Menu</a></span><span>» </span><span><a href="/optin-manager/lists">
                Lists</a></span><span>» </span><span>Edit</span>
        </div>
        <div style="color: Red;">@ViewBag.Message &nbsp;</div>
        <div id="content">
            <h2>
                Edit Mailing List</h2>
            <div>
            <form id="form1" action="" method="post">
            <table cellspacing="0" border="0" style="border-collapse: collapse;">
                <tbody>
                    <tr>
                        <td>
                            <table width="600" cellspacing="0" cellpadding="5" border="0" class="frame">
                                <tbody>
                                    <tr>
                                        <td colspan="2" class="toolbar">
                                            <a href="javascript:void(0);" onclick="SaveList();">                                            
                                                <img border="0" src="/areas/mvccmsoptin/content/buttons/save.gif" id="update" name="update">
                                            </a>
                                            <a href="javascript:void(0);" onclick="DeleteList();">
                                                <img border="0" src="/areas/mvccmsoptin/content/buttons/delete.gif" id="delete" name="delete">
                                            </a>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                            <dl>
                                <dt>Name </dt>
                                <dd>
                                    <input type="text" style="width: 90%;" class="required" id="ListName" value="@Model._List.ListName" name="ListName">
                                </dd>
                                <dt>Description </dt>
                                <dd>
                                    <textarea style="height: 79px; width: 90%;" id="Description" name="Description">@Model._List.Description</textarea>
                                </dd>
                                <dt>Private </dt>
                                <dd>
                                    @Html.CheckBox("Private", Model._List.Private, new { autocomplete="false" })
                                </dd>
                                <dt>Date Created</dt>
                                <dd>
                                    @Model._List.CreateDate by @Model._List.Admin.UserName
                                </dd>
                            </dl>
                        </td>
                    </tr>
                </tbody>
            </table>
            @Html.Hidden("ListID", Model._List.ListID)
            </form>
            </div>
            <div class="MvcCmsDataGrid">        
                <table cellpadding="0" cellspacing="0" border="0" class="display" id="subscribers">
	                <thead>
		                <tr>
			                <th>Name</th>
			                <th>Email</th>
			                <th>DoNotContact</th>
			                <th>Format</th>                      
		                </tr>
	                </thead>
	                <tbody></tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<select class="optinSearchListParams" id="SearchColumns">
    <option value="All">All</option>
    <option value="Name">Name</option>
    <option value="Email">Email</option>
    <option value="DoNotContact">Do Not Contact</option>
    <option value="Format">Format</option>
</select>
@section ScriptContent{
    <script src="@Url.Content("/areas/mvccmsoptin/scripts/jquery.dataTables.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("/areas/mvccmsoptin/scripts/dataTableExt.oApi.fnSetFilteringPressEnter.js")" type="text/javascript"></script>
    <script src="@Url.Content("/areas/mvccmsoptin/Scripts/jquery.validate.js")" type="text/javascript"></script>
    <script type="text/javascript">
        function SaveList() {
            $("#form1").submit();
        }
        function DeleteList() {
            $("#form1").attr("action", "/optin-manager/deletelist");
            $("#form1").submit();
        }        
        $("#form1").validate();
    </script>
    <script type="text/javascript" charset="utf-8">
        $(document).ready(function () {
            $('#subscribers').dataTable({
                "bProcessing": true,
                "bServerSide": true,
                "iDisplayLength": 10,
                "bLengthChange": true,
                "aaSorting": [[0, 'asc'], [2, 'desc']],
                "aLengthMenu": [10, 20, 40],
                "aoColumns": [
                    { "sName": "Name", "sWidth": "45%" },
                    { "sName": "Email" },
                    { "sName": "DoNotContact" },
                    { "sName": "Format" }
                ],
                "bJQueryUI": true,
                "sPaginationType": "full_numbers",
                "sAjaxSource": "/optinajax/listsubscribersforlist/@Model._List.ListID",
                "fnInitComplete": function () {
                    var searchFilter = $("#SearchColumns");
                    $("#subscribers_filter").append(searchFilter);
                },
                "fnServerData": function (sSource, aoData, fnCallback) {
                    aoData.push({ name: "sSingleSearchField", value: $("#SearchColumns").val() });
                    $.ajax({
                        "dataType": 'json',
                        "type": "POST",
                        "url": sSource,
                        "data": aoData,
                        "success": fnCallback
                    })
                }
            }).fnSetFilteringPressEnter();
        });
    </script>
}
